home *** CD-ROM | disk | FTP | other *** search
- /*
- File: QTICSamplePanle.c
-
- Contains: QTIC Sample Panel.
-
- Written by: Dino Tang
-
- Copyright: © 1996-1997 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 04/25/97 DT First created.
-
- To Do:
-
- */
-
- #include <Types.h>
- #include <Errors.h>
- #include <Memory.h>
- #include <Resources.h>
- #include <TextUtils.h>
- #include <QDOffscreen.h>
- #include <TextUtils.h>
-
- #include "QTICSamplePanel.h"
-
- /* ------------------------------------------------------------------------- */
-
- RoutineDescriptor MainRD = BUILD_ROUTINE_DESCRIPTOR(uppMainProcInfo, QTICSAMPLEPANEL);
-
- /* ------------------------------------------------------------------------- */
-
- pascal Boolean DLOGU_anyClickDialogFilter(DialogRef theDialog, EventRecord *theEvent, short *itemHit);
- void PANELU_LoadStringFromRsrc( short id, short maxSize, unsigned char *str, unsigned char *defaultStr);
-
- /* ------------------------------------------------------------------------- */
-
- // Component entry point.
-
- pascal ComponentResult QTICSAMPLEPANEL(ComponentParameters *params, char **storage)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( params->what < 0 ) {
- switch ( params->what ) {
- case kComponentOpenSelect:
- return ( CallComponentFunctionUniv(params, QTICP_Open) );
- case kComponentCloseSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_Close) );
- case kComponentCanDoSelect:
- return ( CallComponentFunctionUniv(params, QTICP_CanDo) );
- case kComponentTargetSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_Target) );
- case kComponentVersionSelect:
- return ( kQTICPanelVersion );
- default:
- return ( unimpErr );
- }
- } else {
- switch ( params->what ) {
- case kQTICPAboutBoxSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_AboutBox) );
- case kQTICPInitializeSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_Initialize) );
- case kQTICPSetControlsSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_SetControls) );
- case kQTICPGetSettingsSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_GetSettings) );
- case kQTICPSetSettingsSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_SetSettings) );
- case kQTICPCanUseCameraSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_CanUseCamera) );
-
- case kQTICPIsPanelSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_IsPanel) );
- case kQTICPCloseWindowSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_CloseWindow) );
- case kQTICPEventSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_Event) );
- case kQTICPIdleSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_Idle) );
- case kQTICPInContentDoubleSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_InContentDouble) );
- case kQTICPInContentSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_InContent) );
- case kQTICPGetGrowSizeSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_GetGrowSize) );
- case kQTICPGrowWindowSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_GrowWindow) );
- case kQTICPZoomWindowSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_ZoomWindow) );
- case kQTICPDoKeyDownSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_DoKeyDown) );
- case kQTICPDrawSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_Draw) );
- case kQTICPUpdateCustomMenuSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_UpdateCustomMenu) );
- case kQTICPDoCustomMenuSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_DoCustomMenu) );
- case kQTICPGetMenuNameSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_GetMenuName) );
- case kQTICPFinishCustomMenuSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_FinishCustomMenu) );
- case kQTICPActivateSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_Activate) );
- case kQTICPDeactivateSelect:
- return ( CallComponentFunctionWithStorageUniv(storage, params, QTICP_Deactivate) );
-
- default:
- return ( unimpErr );
- }
- }
- }
-
- /* ------------------------------------------------------------------------- */
-
- // Required component calls.
-
- pascal ComponentResult QTICP_Open(ComponentInstance self)
- {
- PrivateGlobals **myPrivateGlobals;
-
- myPrivateGlobals = nil;
-
- // Create private variables.
- myPrivateGlobals = (PrivateGlobals **) NewHandleClear(sizeof(PrivateGlobals));
- if ( myPrivateGlobals == nil )
- goto bail;
- MoveHHi((Handle) myPrivateGlobals);
- HLock((Handle) myPrivateGlobals);
-
- // Initialize private variables.
- (**myPrivateGlobals).delegate = 0;
- (**myPrivateGlobals).self = self;
- (**myPrivateGlobals).controls = nil;
- (**myPrivateGlobals).callback = nil;
-
- (**myPrivateGlobals).window = nil;
-
- // Since we've gotten here, everythings ok and we can set up the connection.
- SetComponentInstanceStorage(self, (Handle) myPrivateGlobals);
-
- return ( kQTIC_noErr );
-
- bail:
- if ( myPrivateGlobals != nil ) {
- DisposeHandle((Handle) myPrivateGlobals);
- myPrivateGlobals = nil;
- }
-
- return ( kQTIC_memFullErr );
- }
-
- pascal ComponentResult QTICP_Close(Handle storage, ComponentInstance self)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- // Dispose of private variables.
- if ( myPrivateGlobals != nil ) {
- // This clears our controls callbacks.
- if ( (**myPrivateGlobals).controls != nil && (**myPrivateGlobals).callback != nil ) {
- QTICCRemoveActionFilter((**myPrivateGlobals).controls, (**myPrivateGlobals).callback, (long) myPrivateGlobals);
- DisposeRoutineDescriptor((**myPrivateGlobals).callback);
- (**myPrivateGlobals).callback = nil;
- }
-
- // Put the stuff you need to dispose for your panel here.
- if ( (**myPrivateGlobals).window != nil )
- DisposeWindow((**myPrivateGlobals).window);
-
- DisposeHandle((Handle) myPrivateGlobals);
- }
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_CanDo(short selector)
- {
- switch ( selector ) {
- case kComponentOpenSelect:
- case kComponentCloseSelect:
- case kComponentCanDoSelect:
- case kComponentVersionSelect:
- case kComponentTargetSelect:
-
- case kQTICPInitializeSelect:
- case kQTICPAboutBoxSelect:
- case kQTICPGetSettingsSelect:
- case kQTICPSetSettingsSelect:
- case kQTICPSetControlsSelect:
- case kQTICPCanUseCameraSelect:
-
- case kQTICPIsPanelSelect:
- case kQTICPCloseWindowSelect:
- case kQTICPEventSelect:
- case kQTICPIdleSelect:
- case kQTICPInContentDoubleSelect:
- case kQTICPInContentSelect:
- case kQTICPGetGrowSizeSelect:
- case kQTICPGrowWindowSelect:
- case kQTICPZoomWindowSelect:
- case kQTICPDoKeyDownSelect:
- case kQTICPDrawSelect:
- case kQTICPUpdateCustomMenuSelect:
- case kQTICPDoCustomMenuSelect:
- case kQTICPGetMenuNameSelect:
- case kQTICPFinishCustomMenuSelect:
- case kQTICPActivateSelect:
- case kQTICPDeactivateSelect:
- return ( true );
- default:
- return ( false );
- }
- }
-
- pascal ComponentResult QTICP_Target(Handle storage, ComponentInstance self)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- // From now on, self will be the component instance that targeted us.
- (**myPrivateGlobals).self = self;
-
- return ( kQTIC_noErr );
- }
-
- /* ------------------------------------------------------------------------- */
-
- pascal ComponentResult QTICP_AboutBox(Handle storage)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
- short itemHit;
- DialogPtr myDialog;
- ModalFilterUPP myRoutine;
- short resFile;
- short resFileComp;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- resFile = CurResFile();
- resFileComp = OpenComponentResFile((Component) (**myPrivateGlobals).self);
-
- myRoutine = NewModalFilterProc(DLOGU_anyClickDialogFilter);
- myDialog = GetNewDialog(kDLOG_ABOUT, 0, (WindowRef) -1);
- SetGWorld((CGrafPtr) myDialog, GetMainDevice());
- do {
- ModalDialog(myRoutine, &itemHit);
- } while ( (itemHit != ok) );
- DisposeDialog(myDialog);
- DisposeRoutineDescriptor(myRoutine);
-
- CloseComponentResFile(resFileComp);
- UseResFile(resFile);
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_Initialize(Handle storage, Handle settings)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
- QTICPanelSettings **standardSettings = (QTICPanelSettings **) settings;
- short resFile;
- short resFileComp;
- Rect boundsRect;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- boundsRect.left = 4;
- boundsRect.top = 44;
- boundsRect.bottom = boundsRect.top + 64;
- boundsRect.right = 254;
-
- // If you need to get any resources stored in the component file, put it between OpenComponentResFile & CloseComponentResFile.
- resFile = CurResFile();
- resFileComp = OpenComponentResFile((Component) (**myPrivateGlobals).self);
-
- PANELU_LoadStringFromRsrc(kSTR_MENUCONNECTED, 255, (**myPrivateGlobals).menuStrConnected, "\pItem 1;(-;Item 2");
- PANELU_LoadStringFromRsrc(kSTR_MENUNOTCONNECTED, 255, (**myPrivateGlobals).menuStrNotConnected, "\p(Item 1;(-;(Item 2");
-
- // If you need to get any resources stored in the component file, put it between OpenComponentResFile & CloseComponentResFile.
- CloseComponentResFile(resFileComp);
- UseResFile(resFile);
-
- // Create window.
- (**myPrivateGlobals).window = NewCWindow(nil, &boundsRect, "\pSample", true, noGrowDocProc, (WindowRef) -1L, true, (long) myPrivateGlobals);
- SetGWorld((CGrafPtr) (**myPrivateGlobals).window, GetMainDevice());
-
- // Use settings values that are only used at initialize time.
-
- // Settings is nil. This is usually used when user selects "New".
- if ( standardSettings == nil ) {
-
- // If settings is not nil, then double check it is the correct settings handle.
- } else if ( (**standardSettings).header.size >= sizeof(QTICSettingsHeader) &&
- (**standardSettings).header.type == kQTICPanelComponentType &&
- (**standardSettings).header.subType == '????' && // Fill in your type.
- (**standardSettings).header.manufacturer == kQTICPComponentManufacturer &&
- (**standardSettings).header.version <= kQTICPanelVersion ) {
- FSSpec theFile;
-
- theFile = (**standardSettings).file;
-
- // Put code here that checks the datatype.
- if ( (**standardSettings).dataType == '????' ) {
- }
- }
-
- // Call SetSettings for settings changes that may occur after initialization.
- return ( QTICPSetSettings((**myPrivateGlobals).self, settings) );
- }
-
- pascal Boolean CameraCallBack(QTICControls qtcc, short action, void *param1, void *param2, void *param3, void *param4, long refCon);
- pascal Boolean CameraCallBack(QTICControls qtcc, short action, void *param1, void *param2, void *param3, void *param4, long refCon)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) refCon;
- Boolean ret;
-
- // Not handled is default
- ret = false;
-
- // If we aren't initialized, then don't do anything.
- if ( myPrivateGlobals == nil )
- goto done;
-
- // If it isn't our window, then don't do anything.
- switch ( action ) {
- case kQTICActionFileGetMenuFlags:
- case kQTICActionEditGetMenuFlags:
- case kQTICActionFileSave:
- case kQTICActionFileSaveAs:
- case kQTICActionFileGetInfo:
- case kQTICActionFilePageSetup:
- case kQTICActionFilePrint:
- case kQTICActionEditUndo:
- case kQTICActionEditCut:
- case kQTICActionEditCopy:
- case kQTICActionEditPaste:
- case kQTICActionEditClear:
- case kQTICActionEditSelectAll:
- case kQTICActionEditSelectNone:
- if ( (**myPrivateGlobals).window != (WindowRef) param1 )
- goto done;
- break;
- default:
- break;
- }
-
- // OK. Now, we know that it is our window and that we can handle it.
- switch ( action ) {
- case kQTICActionFileGetMenuFlags:
- if ( param2 != nil ) { // param1 is window and param2 is pointer to short
- *((short *) param2) = 0;
- ret = true;
- }
- case kQTICActionFileSave:
- case kQTICActionFileSaveAs:
- case kQTICActionFileGetInfo:
- case kQTICActionFilePageSetup:
- case kQTICActionFilePrint:
- ret = true;
- break;
- case kQTICActionEditGetMenuFlags:
- if ( param2 != nil ) { // param1 is window and param2 is pointer to short
- *((short *) param2) = 0;
- ret = true;
- }
- break;
- case kQTICActionEditUndo:
- case kQTICActionEditCut:
- case kQTICActionEditCopy:
- case kQTICActionEditPaste:
- case kQTICActionEditClear:
- case kQTICActionEditSelectAll:
- case kQTICActionEditSelectNone:
- ret = true;
- break;
- default:
- break;
- }
-
- done:
- return ( ret );
- }
-
- pascal ComponentResult QTICP_SetControls(Handle storage, QTICControls qtcc)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- // If we previously had a callback, then we need to remove it.
- if ( (**myPrivateGlobals).controls != nil && (**myPrivateGlobals).callback != nil ) {
- QTICCRemoveActionFilter((**myPrivateGlobals).controls, (**myPrivateGlobals).callback, (long) myPrivateGlobals);
- DisposeRoutineDescriptor((**myPrivateGlobals).callback);
- (**myPrivateGlobals).callback = nil;
- }
-
- // Do we have a new controls component?
- if ( qtcc != nil ) {
- (**myPrivateGlobals).callback = NewQTICActionFilterWithRefConProc(CameraCallBack);
- if ( (**myPrivateGlobals).callback != nil ) {
- QTICCInstallActionFilter(qtcc, (**myPrivateGlobals).callback, (long) myPrivateGlobals);
- }
- }
-
- // Set the controls component.
- (**myPrivateGlobals).controls = qtcc;
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_GetSettings(Handle storage, Handle *settings)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
- DateTimeRec curTime;
-
- if ( myPrivateGlobals == nil || settings == nil )
- return ( kQTIC_paramErr );
-
- // If you don't have anything that need to be returned, just return an error.
- return ( paramErr );
- }
-
- pascal ComponentResult QTICP_SetSettings(Handle storage, Handle settings)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
- QTICPanelSettings **standardSettings = (QTICPanelSettings **) settings;
- short wleftoffset, wtopoffset;
- FSSpec theFile;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- // settings is nil. This is usually used when user selects "New".
- if ( standardSettings == nil ) {
-
- // If settings is not nil, then double check it is the correct settings handle.
- } else if ( (**standardSettings).header.size >= sizeof(QTICSettingsHeader) &&
- (**standardSettings).header.type == kQTICPanelComponentType &&
- (**standardSettings).header.subType == '????' && // Fill in your type.
- (**standardSettings).header.manufacturer == kQTICPComponentManufacturer &&
- (**standardSettings).header.version <= kQTICPanelVersion ) {
-
- wleftoffset = (**standardSettings).windowLoc.left;
- wtopoffset = (**standardSettings).windowLoc.top;
- theFile = (**standardSettings).file;
-
- // Put code here that checks the datatype.
- if ( (**standardSettings).dataType == '????' ) {
- }
- }
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_CanUseCamera(Handle storage, QTICControls qtcc)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
- ComponentDescription descr;
- QTICCamera qtc;
-
- if ( myPrivateGlobals == nil || qtcc == 0 )
- return ( (ComponentResult) false );
-
- return ( (ComponentResult) true ); // USE JUST THIS IF FOR ALL PANELS
- }
-
- /* ------------------------------------------------------------------------- */
-
- pascal ComponentResult QTICP_IsPanel(Handle storage, WindowRef theWindow)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( (ComponentResult) false );
-
- if ( (**myPrivateGlobals).window == theWindow )
- return ( (ComponentResult) true );
-
- return ( (ComponentResult) false );
- }
-
- pascal ComponentResult QTICP_CloseWindow(Handle storage, WindowRef theWindow)
- {
- // This causes the controls component to close out panel instance.
- return ( kQTIC_paramErr );
- }
-
- pascal ComponentResult QTICP_Event(Handle storage, EventRecord *theEvent)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
- CGrafPtr savePort;
- GDHandle saveGD;
- Boolean handled;
- short windowPart;
-
- if ( myPrivateGlobals == nil || theEvent == nil )
- return ( (ComponentResult) false );
-
- handled = false;
-
- GetGWorld(&savePort, &saveGD);
-
- switch ( theEvent->what ) {
- case mouseDown:
- switch ( windowPart ) {
- case inContent:
- break;
- case inDrag:
- break;
- case inGrow:
- break;
- case inGoAway:
- break;
- case inZoomIn:
- case inZoomOut:
- break;
- default:
- break;
- }
- break;
- case keyDown:
- case autoKey:
- break;
- case updateEvt:
- break;
- default:
- break;
- }
-
- // Restore port and device.
- SetGWorld(savePort, saveGD);
-
- return ( (ComponentResult) handled );
- }
-
- pascal ComponentResult QTICP_Idle(Handle storage)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_InContentDouble(Handle storage, WindowRef theWindow, EventRecord *theEvent)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
- Point here;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- here = theEvent->where;
- GlobalToLocal(&here);
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_InContent(Handle storage, WindowRef theWindow, EventRecord *theEvent)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_GetGrowSize(Handle storage, WindowRef theWindow, Rect *size)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- size->left = 10;
- size->right = 500;
- size->top = 10;
- size->bottom = 500;
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_GrowWindow(Handle storage, WindowRef theWindow, Rect *old, Rect *new)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_ZoomWindow(Handle storage, WindowRef theWindow, short windowPart)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_DoKeyDown(Handle storage, WindowRef theWindow, EventRecord *theEvent)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_Draw(Handle storage, WindowRef theWindow)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
- CGrafPtr savePort ;
- GDHandle saveGD ;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- GetGWorld( &savePort, &saveGD ) ;
- SetGWorld( (CGrafPtr)(**myPrivateGlobals).window, GetMainDevice() ) ;
- MoveTo( 50, 40);
- TextSize( 24 );
- DrawString( "\pSample Panel" ) ;
- SetGWorld( savePort, saveGD ) ;
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_UpdateCustomMenu(Handle storage, WindowRef theWindow, MenuHandle mHandle)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
- ComponentResult cerr;
- Boolean connected;
-
- if ( myPrivateGlobals == nil || mHandle == nil )
- return ( kQTIC_paramErr );
-
- AppendMenu( mHandle, (**myPrivateGlobals).menuStrConnected ) ;
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_DoCustomMenu(Handle storage, WindowRef theWindow, MenuHandle mHandle, short selectedItem)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- switch ( selectedItem ) {
- case 1:
- SysBeep(50);
- break;
- case 3:
- SysBeep(50);
- SysBeep(50);
- break;
- }
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_GetMenuName(Handle storage, WindowRef theWindow, unsigned char *name)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil || name == nil )
- return ( kQTIC_paramErr );
-
- BlockMove("\pSample", name, 7);
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_FinishCustomMenu(Handle storage, WindowRef theWindow, MenuHandle mHandle)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_Activate(Handle storage, WindowRef theWindow)
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- return ( kQTIC_noErr );
- }
-
- pascal ComponentResult QTICP_Deactivate(Handle storage, WindowRef theWindow)
-
- {
- PrivateGlobals **myPrivateGlobals = (PrivateGlobals **) storage;
-
- if ( myPrivateGlobals == nil )
- return ( kQTIC_paramErr );
-
- return ( kQTIC_noErr );
- }
-
- // Any click dialog filter.
- pascal Boolean DLOGU_anyClickDialogFilter(DialogRef theDialog, EventRecord *theEvent, short *itemHit)
- {
- if ( theEvent->what != mouseDown )
- return ( false );
- else {
- *itemHit = ok;
- return ( true );
- }
- }
-
- void PANELU_LoadStringFromRsrc( short id, short maxSize, unsigned char *str, unsigned char *defaultStr)
- {
- StringHandle strH;
- long size;
-
- // Try string from resource first.
- strH = GetString( id );
- if ( strH && *strH ) {
- size = GetHandleSize((Handle) strH);
- if ( (size-1) > maxSize )
- size = maxSize;
- else if ( size < 0 )
- size = 0;
- HLock((Handle) strH);
- BlockMoveData(*strH, str, size);
- str[0] = size-1;
- ReleaseResource( (Handle) strH );
-
- // If we can't get resoruce, try default string.
- } else if ( defaultStr != nil ) {
- size = defaultStr[0];
- if ( size > maxSize )
- size = maxSize;
- else if ( size < 0 )
- size = 0;
- BlockMoveData(defaultStr, str, size+1);
- str[0] = size;
-
- // All else fails, null string.
- } else
- str[0] = 0;
- }
-